package com.lc.qianrenshiye.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lc.qianrenshiye.BaseActivity;
import com.lc.qianrenshiye.BaseApplication;
import com.lc.qianrenshiye.R;
import com.lc.qianrenshiye.conn.Conn;
import com.lc.qianrenshiye.conn.VipBenefitGet;
import com.lc.qianrenshiye.uitls.MyAnimationUitls;
import com.lc.qianrenshiye.uitls.MyToast;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.http.AsyCallBack;

/**
 * Created by Administrator on 2016/11/23.
 */
public class VipActivity extends BaseActivity implements View.OnClickListener {

    @BoundView(R.id.vip_ll) private LinearLayout vip_ll;
    @BoundView(R.id.vip_level_tv) private TextView vip_level_tv;
    @BoundView(R.id.vip_integral_tv) private TextView vip_integral_tv;
    @BoundView(R.id.vip_up_level_less_tv) private TextView vip_up_level_less_tv;
    @BoundView(R.id.vip_how_up_tv) private TextView vip_how_up_tv;
    @BoundView(R.id.vip_vip_level_tv) private TextView vip_vip_level_tv;
    @BoundView(R.id.vip_level_text_tv) private TextView vip_level_text_tv;
    @BoundView(R.id.vip_content_top1_tv) private TextView vip_content_top1_tv;
    @BoundView(R.id.vip_content_top2_tv) private TextView vip_content_top2_tv;
    @BoundView(R.id.vip_content_top3_tv) private TextView vip_content_top3_tv;

    private VipBenefitGet vipBenefitGet = new VipBenefitGet(new AsyCallBack<VipBenefitGet.VipEntity>() {

        @Override
        public void onSuccess(String toast, int type, VipBenefitGet.VipEntity vipEntity) throws Exception {

            vip_level_tv.setText(vipEntity.level);
            vip_integral_tv.setText(vipEntity.integral);
            vip_up_level_less_tv.setText("距离下一级还有" + vipEntity.need);

            vip_vip_level_tv.setText("0" + vipEntity.level);
            vip_level_text_tv.setText(vipEntity.name);// 例子  会员一级

            vip_content_top1_tv.setText(vipEntity.contentList.get(0));
            vip_content_top2_tv.setText(vipEntity.contentList.get(1));
            vip_content_top3_tv.setText(vipEntity.contentList.get(2));

            MyAnimationUitls.toVisibleAnim(vip_ll);
        }

        @Override
        public void onFail(String toast, int type) throws Exception {

            MyToast.showToast(toast, context);

        }
    });

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vip);

        setBackTrue();

        setTitleName(getString(R.string.vip_title_text));

        vipBenefitGet.sid = BaseApplication.BasePreferences.readShopId();
        vipBenefitGet.execute(this);

        vip_how_up_tv.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.vip_how_up_tv:

                Bundle bundle = new Bundle();

                bundle.putString("url", Conn.SERVICE + Conn.WEB_LEVEL + "1");
                bundle.putString("title", "如何提升");

                startActivity(new Intent(this, MyWebActivity.class).putExtras(bundle));

                break;
        }
    }
}
